{extend name="layout" /}
{block name="body"}
<link rel="stylesheet" type="text/css" href="/static/js/bootstrap-datepicker/bootstrap-datepicker3.min.css">
<link rel="stylesheet" type="text/css" href="/static/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" type="text/css" href="/static/js/bootstrap-clockpicker/bootstrap-clockpicker.min.css">
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-body">
                <form name="appinfo">
                    <div class="form-group">
                        <label for="appname">软件名称</label>
                        <input type="hidden" class="form-control" id="id" name="id" value="{$appdown.id}">
                        <input type="text" class="form-control" id="appname" name="appname" value="{$appdown.appname}" placeholder="请输入软件名称">
                    </div>
                    <div class="form-group">
                        <label for="apppage">软件包名</label>
                        <input type="text" class="form-control" id="apppage" name="apppage" value="{$appdown.apppage}"
                            placeholder="请输入软件包名,如com.yuncheng.ruanher">
                    </div>
					<div class="form-group">
					    <label for="appdata">软件大小</label>
					    <input type="text" class="form-control" id="appdata" name="appdata" value="{$appdown.appdata}"
					        placeholder="请输入软件大小,如12.3">
					</div>
					<div class="form-group">
						<label for="appbb">软件版本</label>
						<input type="text" class="form-control" id="appbb" name="appbb" value="{$appdown.appbb}" placeholder="请输入软件版本号,如1.0.0">
					</div>
					<div class="form-group">
						<label for="appmsg">软件介绍</label>
						<textarea class="form-control" id="appmsg" name="appmsg" rows="3"  placeholder="请输入软件介绍">{$appdown.appmsg}</textarea>
					</div>					
					<div class="form-group">
						<label for="appuser">软件作者</label>
						<input type="text" class="form-control" id="appuser" name="appuser" value="{$appdown.appuser}" placeholder="请输入软件作者账号..">
					</div>
					<div class="form-group file-group">
					    <label for="appicon">软件图标</label>
					    <div class="input-group">
					        <input type="text" class="form-control file-value" value="{$appdown.appicon}" name="appicon"
					            value="" placeholder="软件图标" />
					        <input type="file" name="file" accept=".png,.jpg,.jpeg,.bmp,.gif" style="display: none"
					            style="display: none;" />
					        <div class="input-group-btn">
					            <button class="btn btn-default file-browser" type="button">上传图标</button>
					        </div>
					    </div>
					</div>
					<div class="form-group file-group">
					    <label for="apphenfu">软件横幅图</label>
					    <div class="input-group">
					        <input type="text" class="form-control file-value" value="{$appdown.apphenfu}" name="apphenfu"
					            value="" placeholder="软件图标" />
					        <input type="file" name="file" accept=".png,.jpg,.jpeg,.bmp,.gif" style="display: none"
					            style="display: none;" />
					        <div class="input-group-btn">
					            <button class="btn btn-default file-browser" type="button">上传横幅</button>
					        </div>
					    </div>
					</div>
					<div class="form-group file-apkgroup">
						<label for="appdownurl">上传软件</label>
						<div class="input-group">
							<input type="text" id="appdownurl" class="form-control file-apkvalue" value="{$appdown.appdownurl}" name="appdownurl"
								placeholder="请输入软件链接地址">
							<input type="file" accept=".apk" style="display: none">
							<div class="input-group-btn">
								<button class="btn btn-default file-apk" type="button">上传软件</button>
							</div>
						</div>
					</div>
					<div class="form-group">
						<label for="appsortid">软件分类</label>
						<select class="form-control" id="appsortid"  name="appsortid"> 
						{foreach :query('appdownsort') as $key=>$value }
							<option value="{$value['id']}" {if $appdown['appsortid']==$value['id'] }selected{/if}>{$value["sortname"]}(分类ID:{$value['id']})</option>
						{/foreach}
						</select>
					</div>					
					<div class="form-group">
						<label for="apptag">软件标签</label>
						<input type="text" class="form-control" id="apptag" value="{$appdown.apptag}" name="apptag" placeholder="请输入软件标签名称,用英文;分割">
					</div>
					<div class="form-group file-groups">
					  <label for="appsce">软件截图</label>					
					  <div class="js-upload-image">
						<ul id="file_list_more_pic" class="list-inline lyear-uploads-pic">							
						</ul>
						<input type="hidden" type="text" id="appsce" class="form-control file-values"  value="{$appdown.appsce}" name="appsce"
							placeholder="请输入软件截图链接地址">
						<button class="btn btn-success file-browsers" type="button">上传截图</button>
					    <input type="file" accept=".png,.jpg,.jpeg,.bmp,.gif" style="display: none">					    				    
					  </div>					  
					</div>
					<div class="form-group">
						<label for="appmod">是否MOD版本</label>
						<select class="form-control" id="appmod" name="appmod">
							<option value="0" {if $appdown['appmod']==0 }selected{/if}>否</option>
							<option value="1" {if $appdown['appmod']==1 }selected{/if}>是</option>
						</select>
					</div>
					<div class="form-group">
						<label for="appisvip">下载方式</label>
						<select class="form-control" id="appisvip" name="appisvip">
							<option value="0" {if $appdown['appisvip']==0 }selected{/if}>免费下载</option>
							<option value="1" {if $appdown['appisvip']==1 }selected{/if}>会员下载</option>
						</select>
					</div>
					<div class="form-group">
						<label for="apptop">是否精选</label>
						<select class="form-control" id="apptop" name="apptop">
							<option value="0" {if $appdown['apptop']==0 }selected{/if}>否</option>
							<option value="1" {if $appdown['apptop']==1 }selected{/if}>是</option>
						</select>
					</div>
                    <button type="button" onclick="updateapp()" class="btn btn-w-sm btn-primary mb-2">提交</button>
                    <button type="button" class="btn btn-default mb-2"
                        onclick="javascript:history.back(-1);return false;">返
                        回
                    </button>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<!--时间日期选择器-->
<script type="text/javascript" src="/static/js/momentjs/moment.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="/static/js/momentjs/locale/zh-cn.min.js"></script>
<script>	
	$(document).ready(function () {
	    var imgs = $('.file-values').val().split(',');
	    var html = '';
	    $.each(imgs, (index, img) => {
	        html += '<li class="col-xs-4 col-sm-t3" id="delsec">'+
	        '<figure>'+
	        '<img src="' +
	        img +
	        '">'+
	        '<figcaption>'+
	        '<div class="btn btn-round btn-square btn-danger" >'+
	        '<i class="mdi mdi-delete">'+
	        '</i>'+
	        '</div>'+
	        '</figure>'+
	        '</li>';
	    });
	    $('#file_list_more_pic').html(html);
	});
	

    function updateapp() {
        var l = $('body').lyearloading({
            opacity: 0.2,
            spinnerSize: 'lg',
            spinnerText: '后台处理中，请稍后...',
            textColorClass: 'text-info',
            spinnerColorClass: 'text-info'
        });
        $.ajax({
            type: "POST",
            url: "{:url('appdown/editapp')}",
            data: $("form").serializeArray(),
            dataType: "json",
            success: function (data) {
                setTimeout(function () {
                    l.destroy();
                }, 1e3)
                if (data.code == 1) {
                    notify.success(data.msg);
                } else {
                    notify.error(data.msg);
                }
            },
            error: function () {
                l.destroy();
                notify.error("系统错误");
            }
        })
    }

</script>
{/block}